import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Home from '@/views/Home/Home.vue'

const Product = () => import('@/views/product/index.vue');
const List = () => import('@/views/product/list/index.vue');
const Category = () => import('@/views/product/category/index.vue');
const Order = () => import('@/views/Order/index.vue');
const OrderList = () => import('@/views/Order/List');
const Collect = () => import('@/views/Order/Collect');
const Advert = () => import('@/views/Advert')
const AdvertList = () => import('@/views/Advert/List')


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: "/",
        name: "home",
        component: Home
      },
      {
        path: "/product", //产品管理
        name: "product",
        component: Product,
        children: [
          {
            path: "list", //访问路径: /product/list
            name: "list",
            component: List
          },
          {
            path: "category", //访问路径: /product/category
            name: "category",
            component: Category
          }
        ]
      },
      {
        path: "/order", //订单管理
        name: "order",
        component: Order,
        children: [
          {
            path: "order-list",
            name: "order-list",
            component: OrderList
          },
          {
            path: "collect", //订单汇总
            name: "collect",
            component: Collect
          }
        ]
      },
      {
        path: "/advert", //广告管理
        name: "advert",
        component: Advert,
        children: [
          {
            path: 'advert-list',
            name: "advert-list",
            component:AdvertList
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: "login",
    component: Login,
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
